<?php
class User_action extends CI_Controller {
    public function __construct() {
        parent::__construct ();
        session_start ();
    }
    public function index() {
        $this->login ();
    }
    
    /**
     *
     * 注册接口
     *
     * @name registry
     * @author Eifel.Deng 2015年3月19日
     */
    public function register() {
         parse_str($GLOBALS['HTTP_RAW_POST_DATA'],$post_data);
        

        $data ['account_no'] = $post_data['account'];
        $data ['password'] = $post_data['password'];
        $data ['device_imei'] = $post_data['did'];
        $data ['device_name'] = $post_data['dn'];
        $data ['mer_id'] = $post_data['app_id'];
        $data ['phone_num'] = "";
        $need_login = $this->input->post ( "need_login" );
        $this->load->library ( "/user/sdk_user" );
        $result = $this->sdk_user->register ( $data, $need_login );
        echo json_encode ( $result );
    }
    /**
     *
     * 登录接口
     *
     * @name login
     * @author Eifel.Deng 2015年3月19日
     */
    public function login() {
        parse_str($GLOBALS['HTTP_RAW_POST_DATA'],$post_data);
        $data ['account_no'] = $post_data['account'];
        $data ['password'] = $post_data['password'];
        $data ['mer_id'] = $post_data['app_id'];
        $this->load->library ( "/user/sdk_user" );
        $result = $this->sdk_user->login ( $data );
        echo json_encode ( $result );
    }
    public function change_password() {
        $data ['account_no'] = $this->input->post ( "account_no" );
        $data ['old_password'] = $this->input->post ( "old_password" );
        $data ['new_password'] = $this->input->post ( "new_password" );
        $data ['mer_id'] = $this->input->post ( "mer_id" );
        $this->load->library ( "/user/sdk_user" );
        $result = $this->sdk_user->change_password ( $data );
        echo json_encode ( $result );
    }
    public function logout() {
        $data ['account_no'] = $this->input->post ( "account_no" );
        $data ['mer_id'] = $this->input->post ( "mer_id" );
        $this->load->library ( "/user/sdk_user" );
        $result = $this->sdk_user->logout ( $data );
        echo json_encode ( $result );
    }
    public function send_bind_message_code() {
        $account_no = $this->input->post ( "account_no" );
        $phone_num = $this->input->post ( "phone_num" );
        $this->load->library ( "/user/sdk_user" );
        $result = $this->sdk_user->send_bind_message_code ( $account_no, $phone_num );
        echo json_encode ( $result );
    }
    public function check_bind_message_code() {
        $account_no = $this->input->post ( "account_no" );
        $code = $this->input->post ( "code" );
        $this->load->library ( "/user/sdk_user" );
        $result = $this->sdk_user->check_bind_message_code ( $account_no, $code );
        echo json_encode ( $result );
    }
    
    
    public function add_log(){
        
        
    }
    
}

/**
 *End of file 'user_action.php';
 *Location './mpay/controllers/user_action.php'
 */